<j:ebuttons
  [searchPlaceholder]="'BasicArchives::UI:MulitEntity.JButtons.SearchPlaceholder' | abpLocalization"
  [editState]="editState"
  [submitBtnVisible]="false"
  [backBtnVisible]="false"
  [approveBtnVisible]="false"
  [unapproveBtnVisible]="false"
  [approveDividerVisible]="false"
  [selectBtnVisible]="false"
  [listBtnVisible]="false"
  [searchDividerVisible]="false"
  (saveBtnClick)="save()"
  (giveupBtnClick)="giveup()"
  (newBtnClick)="new()"
  (copyBtnClick)="copy()"
  (deleteBtnClick)="delete()"
  (refreshBtnClick)="refresh()"
  (searchBtnClick)="search($event)"
>
</j:ebuttons>
<form nz-form [formGroup]="validateForm">
  <nz-card class="main-card">  
    <nz-tabset nzType="card">
      <nz-tab [nzTitle]="'BasicArchives::UI:MulitEntity.CardTitle.Base' | abpLocalization">
        <div nz-row>
          <div nz-col [nzSpan]="8">
            <nz-form-item>
              <nz-form-label [nzSm]="8" [nzXs]="24" nzRequired nzFor="code">
                <a nz-button nzType="link" class="ref-form-label" (click)="uniqueCodeSetting()">
                  {{ 'BasicArchives::ModelTitle:Joy.Erp.BasicArchives.ItemMasters.UnitGroup.Code' | abpLocalization }}
                </a>
              </nz-form-label>
              <nz-form-control [nzSm]="14" [nzXs]="24" nzHasFeedback>
                <input
                  nz-input
                  id="code"
                  formControlName="code"
                  [placeholder]="'BasicArchives::ModelPlaceHolder:Joy.Erp.BasicArchives.ItemMasters.Unit.Code' | abpLocalization"
                  [readonly]="codeInputDisabled"
                  [ngClass]="{ 'input-disabled': codeInputDisabled }"
                  nz-tooltip
                  [nzTooltipTitle]="getErrorMessage('code')"
                  [nzTooltipVisible]="validateForm.get('code')?.invalid && validateForm.get('code')?.touched"
                  nzTooltipPlacement="top"
                />
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="8"></div>
          <div nz-col [nzSpan]="8"></div>
          <div nz-col [nzSpan]="8">
            <nz-form-item>
              <nz-form-label [nzSm]="8" [nzXs]="24" nzRequired nzFor="groupName">
                {{ 'BasicArchives::ModelTitle:Joy.Erp.BasicArchives.ItemMasters.UnitGroup.GroupName' | abpLocalization }} 
              </nz-form-label>
              <nz-form-control [nzSm]="14" [nzXs]="24" nzHasFeedback>
                <input
                  nz-input
                  id="groupName"
                  formControlName="groupName"
                  [placeholder]="'BasicArchives::ModelPlaceHolder:Joy.Erp.BasicArchives.ItemMasters.UnitGroup.GroupName' | abpLocalization"
                  nz-tooltip
                  [nzTooltipTitle]="getErrorMessage('groupName')"
                  [nzTooltipVisible]="validateForm.get('groupName')?.invalid && validateForm.get('groupName')?.touched"
                  nzTooltipPlacement="top"
                />
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="8"></div>
          <div nz-col [nzSpan]="8"></div>
          <div nz-col [nzSpan]="8">
            <nz-form-item>
              <nz-form-label [nzSm]="8" [nzXs]="24" nzRequired nzFor="MainUnitId">
                {{ 'BasicArchives::ModelTitle:Joy.Erp.BasicArchives.ItemMasters.UnitGroup.MainUnitId' | abpLocalization }} 
              </nz-form-label>
              <nz-form-control [nzSm]="14" [nzXs]="24" nzHasFeedback>
                <widget-entity-ref-select
                  [formControlName]="'mainUnitId'"
                  [placeholder]="'BasicArchives::ModelPlaceHolder:Joy.Erp.BasicArchives.ItemMasters.UnitGroup.MainUnitId' | abpLocalization"
                  [idKey]="'id'"
                  [labelKey]="'displayName'"
                  [showSelect]="showMainUnitSelect"
                  [getDetail]="getMainUnitDetail"
                  readonly
                  nz-tooltip
                  [nzTooltipTitle]="getErrorMessage('mainUnitId')"
                  [nzTooltipVisible]="validateForm.get('mainUnitId')?.invalid && validateForm.get('mainUnitId')?.touched"
                  nzTooltipPlacement="top"
                >
                </widget-entity-ref-select>
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="8"></div>
          <div nz-col [nzSpan]="8"></div>
        </div>
      </nz-tab>
    </nz-tabset>
  </nz-card>
  <nz-card class="line-card">
    <nz-tabset nzType="card">
      <nz-tab [nzTitle]="'BasicArchives::UI:MulitEntity.CardTitle.Details' | abpLocalization">
        <nz-table
          #childTable
          nzSize="middle"
          [nzData]="children.controls"
          [nzShowPagination]="false"
          [nzFrontPagination]="false"
          [nzShowSizeChanger]="true"
          [nzScroll]="{ x: '100%', y: '100%' }"
          [nzBordered] = "true"
          [nzNoResult] = "noResult"
          (contextmenu)="contextMenu($event, menuTable)"
        >
          <nz-dropdown-menu #menuTable="nzDropdownMenu">
            <ul nz-menu>
              <li nz-menu-item (click)="addChild()">{{ 'BasicArchives::UI:MulitEntity.ContextMenu.Add' | abpLocalization }}</li>
            </ul>
          </nz-dropdown-menu>
          <ng-template #noResult class="no-result">
          </ng-template>
          <thead>
            <tr>
              <th [nzWidth]="'150px'">
                {{ 'BasicArchives::ModelTitle:Joy.Erp.BasicArchives.ItemMasters.AuxiliaryUnit.UnitId' | abpLocalization }}
              </th>
              <th [nzWidth]="'200px'">
                {{ 'BasicArchives::ModelTitle:Joy.Erp.BasicArchives.ItemMasters.AuxiliaryUnit.MainToAuxiliaryRatio' | abpLocalization }}
              </th>
              <th [nzWidth]="'200px'">
                {{ 'BasicArchives::ModelTitle:Joy.Erp.BasicArchives.ItemMasters.AuxiliaryUnit.AuxiliaryToMainRatio' | abpLocalization }}
              </th>
            </tr>
          </thead>
          <tbody>
            <tr *ngFor="let child of children.controls; let i = index" (contextmenu)="contextMenu($event, menuRow)">
              <nz-dropdown-menu #menuRow="nzDropdownMenu">
                <ul nz-menu>
                  <li nz-menu-item (click)="addChild()">{{ 'BasicArchives::UI:MulitEntity.ContextMenu.Add' | abpLocalization }}</li>
                  <li nz-menu-item (click)="removeChild(i)">{{ 'BasicArchives::UI:MulitEntity.ContextMenu.Delete' | abpLocalization }}</li>
                </ul>
              </nz-dropdown-menu>
              <td>
                <nz-form-item>
                  <nz-form-control nzHasFeedback>
                    <widget-entity-ref-select
                      [formControl]="child.get('unitId')"
                      [placeholder]="'BasicArchives::ModelPlaceHolder:Joy.Erp.BasicArchives.ItemMasters.AuxiliaryUnit.UnitId' | abpLocalization"
                      [idKey]="'id'"
                      [labelKey]="'displayName'"
                      [showSelect]="showMainUnitSelect"
                      [getDetail]="getMainUnitDetail"
                      nz-tooltip
                      [nzTooltipTitle]="getControlErrorMessage(child, 'unitId')"
                      [nzTooltipVisible]="child.get('unitId')?.invalid && child.get('unitId')?.touched"
                      nzTooltipPlacement="top"
                    >
                    </widget-entity-ref-select>
                  </nz-form-control>
                </nz-form-item>
              </td>
              <td>
                <nz-form-item>
                  <nz-form-control nzHasFeedback>
                    <input
                      nz-input
                      [formControl]="child.get('mainToAuxiliaryRatio')"
                      [placeholder]="'BasicArchives::ModelPlaceHolder:Joy.Erp.BasicArchives.ItemMasters.AuxiliaryUnit.MainToAuxiliaryRatio' | abpLocalization"
                      nz-tooltip
                      [nzTooltipTitle]="getControlErrorMessage(child, 'mainToAuxiliaryRatio')"
                      [nzTooltipVisible]="child.get('mainToAuxiliaryRatio')?.invalid && child.get('mainToAuxiliaryRatio')?.touched"
                      nzTooltipPlacement="top"
                    />
                  </nz-form-control>
                </nz-form-item>
              </td>
              <td>
                <nz-form-item>
                  <nz-form-control nzHasFeedback>
                    <input
                      nz-input
                      [formControl]="child.get('auxiliaryToMainRatio')"
                      [placeholder]="'BasicArchives::ModelPlaceHolder:Joy.Erp.BasicArchives.ItemMasters.AuxiliaryUnit.AuxiliaryToMainRatio' | abpLocalization"
                      nz-tooltip
                      [nzTooltipTitle]="getControlErrorMessage(child, 'auxiliaryToMainRatio')"
                      [nzTooltipVisible]="child.get('auxiliaryToMainRatio')?.invalid && child.get('auxiliaryToMainRatio')?.touched"
                      nzTooltipPlacement="top"
                    />
                  </nz-form-control>
                </nz-form-item>
              </td>
            </tr>
          </tbody>
        </nz-table> 
      </nz-tab>
    </nz-tabset>
  </nz-card>
</form>